/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.edu.unal.bioingenium.kbmed.data.loader;

import co.edu.unal.bioingenium.kbmed.data.PhysicalDocument;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Luis A Riveros
 */
public class SaruroLoader implements DocumentLoader {

    private final String type = "SAR";
    private Set<String> desiredTags;

    public SaruroLoader() {
        desiredTags = new HashSet<String>();

    }

    @Override
    public PhysicalDocument parseDocument(String corpusPath, String fileName) {
        try {
            File file = new File(corpusPath + fileName);
            StringBuilder tempContent = new StringBuilder();
            String line;
            BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
            while ((line = bufferedReader.readLine()) != null) {
                tempContent.append(line).append("\n");
            }
            bufferedReader.close();
            PhysicalDocument document = new PhysicalDocument(fileName);
            document.setType(type);
            document.setSize(file.length());
            document.setLastModified(new Date(file.lastModified()));
            document.setContent(tempContent.toString());
            return document;
        } catch (IOException ex) {
            Logger.getLogger(TXTLoader.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
    }
}
